package cn.unknowpupil.init.domain.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.common.collect.Lists;
import lombok.Data;

import java.util.List;

/**
 * Created at 2020/11/13 by w10g <br>
 * Initialize MenuNode ... <br>
 *
 * @author unknowpupil
 * @since 0.0.1
 */

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class MenuNode {
    @JsonIgnore
    private Long id;
    @JsonIgnore
    private Long parentId;
    /**
     * 路由名字
     */
    private String name;

    /**
     * 路由地址
     */
    private String path;

    /**
     * 是否隐藏路由，当设置 true 的时候该路由不会再侧边栏出现
     */
    private boolean hidden;

    /**
     * 重定向地址，当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
     */
    private String redirect;

    /**
     * 组件地址
     */
    private String component;

    /**
     * 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
     */
    private Boolean alwaysShow;

    /**
     * 其他元素
     */
    private MetaVo meta;
    /**
     * 子路由
     */


    private List<MenuNode> children;

//    private Long id;
//    private Long parentId;
//    private String fullId;
//    private String label;
//    private String iconClass;
//    private String url;
//    private String component;
//    private Long permissionId;
//    private Integer showOrder;
//    private Boolean hiddenFlag;
//    private List<MenuNode> children;
//
    public MenuNode() {}
//
    public MenuNode(Long id, Long parentId,String name) {
        this.id = id;
        this.parentId = parentId;
        this.name = name;

    }

    public List<MenuNode> getChildren() {
        if (children == null) {
            children = Lists.newArrayList();
        }
        return children;
    }
}
